(HSP3) sample7 [解像度を変更してキャプチャする].hsp

sample\hspdsc\32bit\(HSP3) sample7 [解像度を変更してキャプチャする].hsp » Plain Format

#include "hspdsc.as"
	
	title "キャプチャデバイスの解像度を変更して開く"
	cls 4
	dsc_Init				// 初期化

	// デバイスリスト用の変数を初期化
	sdim devlist, dsc_GetDeviceListSize()
	
	// デバイスリストを変数に格納
	dsc_GetDeviceList devlist, 0
	if stat == 0 || stat == -2 : dialog "デバイスが見つかりません" : end

	color 255, 255, 255 : mes "▼ デバイス一覧"
	objsize 300, 20
	combox did, 100, devlist

	objsize 300,20
	button "↑で選択したデバイスの解像度を↓に表示する",*get

	color 255, 255, 255 : mes "▼ デバイスが対応する解像度一覧"
	speclist = ""
	spec = -1
	objsize 300, 20
	combox spec, 100, speclist
	obj_speclist = stat

	button "↑選択した解像度で開始する", *start
	mes 
	button gosub "終了する",*exit
	onexit gosub *exit

	stop
	
*get
	dsc_SetActiveSel 0
	dsc_Open did, 0, 0, 0, 0
	if stat < 0 : dialog "エラーが発生しました。("+stat+")",1,"DEVICE-ERROR" : stop
	gsel 0, 1

	if dsc_GetDevCapConfigSize(0) <= 0 : stop
	if dsc_GetDevCapConfigSize(1) <= 0 : stop
	if dsc_GetDevCapConfigSize(2) <= 0 : stop

	sdim fps, dsc_GetDevCapConfigSize(0) * 2
	sdim w,   dsc_GetDevCapConfigSize(1) * 2
	sdim h,   dsc_GetDevCapConfigSize(2) * 2

	speclist = ""
	dsc_GetDevCapConfig fps, w, h
	notesel fps

	dim spec_w, notemax
	dim spec_h, notemax
	ddim spec_fps, notemax
	
	repeat notemax
		notesel w
			noteget _w, cnt
			spec_w(cnt) = int(_w)
		notesel h
			noteget _h, cnt
			spec_h(cnt) = int(_h)
		notesel fps
			noteget _fps, cnt
			spec_fps(cnt) = double(_fps)
			
		speclist += "" + _w + "x" + _h + " " + _fps + "fps\n"
	loop

	spec = -1
	objprm obj_speclist, speclist
	
	dsc_Stop
	dsc_Close
	
stop

*start
	if (spec == -1) : dialog "解像度一覧のコンボボックスからなにか選択してください" : stop

	dsc_SetActiveSel 1

	// フレームレートと解像度を指定
	dsc_SetDevFrameRate spec_fps(spec)
	dsc_SetDevWidth spec_w(spec)
	dsc_SetDevHeight spec_h(spec)
	
	// 反映
	dsc_SetDevCapConfig

	dsc_Open did, 2, 0, 1, 1
	if stat < 0 : dialog "エラーが発生しました。("+stat+")",1,"DEVICE-ERROR" : stop

	dsc_Play2
	
stop
	
*exit
	
	dsc_SetActiveSel 1
	dsc_Stop
	dsc_Close
	
end
return